home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.6 KB | 145 lines | [TEXT/CWIE] |
- // RegionObject.cp
-
- #ifndef RegionObject_h
- #include "RegionObject.h"
- #endif
- #ifndef QuickDrawError_h
- #include "QuickDrawError.h"
- #endif
-
- RegionObject::RegionObject()
- : me( NewRgn() )
- {
- QuickDrawError::Check().Throw();
- if ( me == 0 )
- throw QuickDrawError( memFullErr );
- }
-
- RegionObject::RegionObject( RgnHandle source )
- : me( NewRgn() )
- {
- QuickDrawError::Check().Throw();
- if ( me == 0 )
- throw QuickDrawError( memFullErr );
-
- (*this) = source;
- }
-
- RegionObject::RegionObject( const RegionObject& source )
- : me( NewRgn() )
- {
- QuickDrawError::Check().Throw();
- if ( me == 0 )
- throw QuickDrawError( memFullErr );
-
- (*this) = source;
- }
-
- RegionObject::RegionObject( const Rect& source )
- : me( NewRgn() )
- {
- QuickDrawError::Check().Throw();
- if ( me == 0 )
- throw QuickDrawError( memFullErr );
-
- (*this) = source;
- }
-
- RegionObject& RegionObject::Temporary( const Rect& r )
- {
- static RegionObject temporary;
- temporary = r;
- return temporary;
- }
-
- RegionObject& RegionObject::Temporary( RgnHandle r )
- {
- static RegionObject temporary;
- temporary = r;
- return temporary;
- }
-
- bool RegionObject::operator==( const Rect& r ) const
- {
- return Rectangular() && Bounds() == r;
- }
-
- bool RegionObject::operator<=( const Rect& r ) const
- {
- return Bounds() <= r;
- }
-
- bool RegionObject::operator>=( const Rect& r ) const
- {
- RegionObject& temporary( Temporary( r ) );
- temporary -= *this;
- return temporary.IsEmpty();
- }
-
- bool RegionObject::operator<=( RgnHandle r ) const
- {
- RegionObject& temporary( Temporary( me ) );
- temporary -= r;
- return temporary.IsEmpty();
- }
-
- bool RegionObject::operator>=( RgnHandle r ) const
- {
- RegionObject& temporary( Temporary( r ) );
- temporary -= *this;
- return temporary.IsEmpty();
- }
-
- void RegionObject::operator&=( const Rect& r )
- {
- *this &= Temporary( r );
- }
-
- void RegionObject::operator|=( const Rect& r )
- {
- *this |= Temporary( r );
- }
-
- void RegionObject::operator^=( const Rect& r )
- {
- *this ^= Temporary( r );
- }
-
- void RegionObject::operator-=( const Rect& r )
- {
- *this -= Temporary( r );
- }
-
- void RegionObject::Complement( const Rect& r )
- {
- Complement( Temporary( r ) );
- }
-
- bool RegionObject::Intersects( const Rect& r ) const
- {
- RegionObject& temporary( Temporary( r ) );
- temporary &= *this;
- return !temporary.IsEmpty();
- }
-
- bool RegionObject::Intersects( RgnHandle r ) const
- {
- RegionObject& temporary( Temporary( r ) );
- temporary &= *this;
- return !temporary.IsEmpty();
- }
-
- void RegionObject::GlobalToLocal()
- {
- PointObject offset( 0, 0 );
- offset.GlobalToLocal();
- *this += offset;
- }
-
- void RegionObject::LocalToGlobal()
- {
- PointObject offset( 0, 0 );
- offset.LocalToGlobal();
- *this += offset;
- }
-